package Pattern.TemplatePattern.Program.program1;

import java.util.Vector;

public abstract class Application {
    private Vector<Document>docs;//文档对象集合//--------------
    public boolean canOpenDocument(String docName){
        /*判断是否可以打开指定文档，返回真值时表示可以打开，
		 返回假值表示不可打开，此处代码省略*/
        return true;
    }
    public void addDocument(Document aDocument){
        docs.add(aDocument);//-------------------
    }
    public abstract Document doCreateDocument();
    public void openDocument(String docName){
        if(canOpenDocument(docName)){
            System.out.println("文档无法打开");
            return;
        }
        /*Application adoc = new MyApplication();
        adoc.doCreateDocument();
        adoc.openDocument(docName);*/
        Document adoc = new MyDocument();//-------------
        adoc.open(docName);//------------
        adoc.read(docName);//------------
        addDocument(adoc);//------------
    }
}
